
*F1 Grand Prix special system for 2.5 Meg

*Falcon special loader




  clr.w -(sp)
  pea $78000
  pea $78000
  move.w #5,-(sp)
  trap #14
  
  pea srut(pc)
  move.w #38,-(sp)
  trap #14
  
  
srut move.l #$80000,$42e.w *phystop

  lea $1f000,sp


*68030 PMM movement
*to address above used - $300000
  
      lea $300000,a0
      dc.l      $f0104e00      * = pmove crp,(a0) / get PMMU table address
      move.l   4(a0),a1         * address is in lower long word

      lea $300008,a2  *8 bytes more for store pos.
      move.l   a1,(a2)         * .. for restore on exit, not really used here
      move.l   a1,a3         * copy

      lea     $300020,a2   * table new pos

hwp_pmmunohi:   
      move.l   a2,a4         * save pointer to new table
      moveq   #$3f,d7         * 64 longwords to copy... (table size = $100)
hwp_pmmu1:      
      move.l   (a1)+,d1         * get table entry
      btst      #1,d1         * address or descriptor?
      beq.s   hwp_pmmudes      * descriptor, don't change
      sub.l      a3,d1         * address, set to new value
      add.l      a4,d1         * "   
hwp_pmmudes:   
      move.l   d1,(a2)+         * write into new table
      dbf      d7,hwp_pmmu1   *
      move.l   a4,4(a0)         * set pointer to new table
      dc.l      $f0104c00      * = pmove (a0),crp / set new PMMU table address
hwp_pmmudone:



   bclr   #5,$ffff8007.w      * activate STE bus emulation



*Internal speeker off:

*       lea   $ffff8800.w,a0      * PSG
*      move.b   #$e,(a0)         * get current Port A status
*      move.b   (a0),d0          * "
*      bclr   #6,d0              * bit 6 controls Falcon's internal speaker
*      move.b   d0,2(a0)         * write new value to PSG

*End of internal speeker off


*Some + code was for avoid PSG shadow addressing....  ????

  *Falcon part end

  
  lea n1(pc),a0
  lea $50000,a6
  bsr loaddek  

  lea $4ff00,a6
  jsr $50096 *pic out  
  
  lea n2(pc),a0
  lea $99000,a6
  bsr loaddek
 
  lea n22(pc),a0
  lea $90000,a6
  bsr loaddek
  
  lea n3(pc),a0
  lea $d8200,a6
  bsr loaddek
  
  
  lea n4(pc),a0
  lea $ea000,a6
  bsr loaddek
  
  lea n5(pc),a0
  lea $117000,a6
  bsr loaddek
  

  lea n6(pc),a0
  lea $171000,a6
  bsr loaddek

  lea n7(pc),a0
  lea $1cb000,a6
  bsr loaddek

  lea n8(pc),a0
  lea $225000,a6
  bsr loaddek

  lea n1(pc),a0
  lea $50000,a6
  bsr loaddek  

  lea stor(pc),a6
  jsr $50008

  lea byname(pc),a0
  lea $81000,a1
  moveq #100,d0
rdrl move.l (a0)+,(a1)+
  dbf d0,rdrl  
 
  lea stor(pc),a6
  lea pfup(pc),a0
  lea $70000,a1
  move.l a1,a2
  moveq #20,d0
pfl move.l (a0)+,(a1)+
  dbf d0,pfl
  jmp (a2)  


pfup  move.w #$2700,sr
  move.l 8(a6),d0
  move.l 4(a6),d1
  move.w 12(a6),d2
  move.w 14(a6),d3

  lea $99000,a0
  lea $400.w,a1
  move.w #$3f200/4-10,d4
cml move.l (a0)+,(a1)+
  dbf d4,cml

  jmp $400.w
      
*Disk rutines

byname movem.l a0-a1,-(sp)
  move.l d0,-(sp)
  jsr $2a36c
  beq dalje
  move.w $8f6(a6),d1
  and.w #$1e,d1
  bne.s d1
  addq.l #4,sp
  jmp $2a42c *for pos disk & disk 1
d1  moveq #1,d6
  moveq #4,d7
  lea $3fa6c,a0
  bsr logsec
  move.l (sp)+,d0
  movem.l (sp)+,a0-a1
  movem.l a0-a1,-(sp)
  jsr $2a36c
  bra.s dalje1
dalje addq.l #4,sp 
dalje1  jmp $2a3dc


logsec move.l a1,-(sp) 
  move.w $8f6(a6),d1
  btst #2,d1
  bne.s disk3
  btst #3,d1
  bne.s disk4
  btst #1,d1
  bne.s disk2
  move.l (sp)+,a1
  cmp.w #$2d0,d6
  bcc.s fisd
  jmp $2a4f2
fisd jmp $2a52a  
  
disk3 lea $117000,a1
  bra.s lsc
disk4 lea $1cb000,a1
  bra.s lsc
disk2 lea $90000,a1
lsc        
  ext.l d6
  lsl.l #7,d6
  lsl.l #2,d6
  add.l d6,a1
  ext.l d7
  lsl.l #5,d7

  subq.w #1,d7
movl move.l (a1)+,(a0)+
  move.l (a1)+,(a0)+
  move.l (a1)+,(a0)+
  move.l (a1)+,(a0)+
  dbf d7,movl
  
  move.l (sp)+,a1
  clr.l d0
  tst.l d0
  rts
  
  clr.w $8f6(a6)
  jmp $2a2f8

  
  
handl ds.w 1
  
load clr.w -(sp)
  pea (a0)
  move.w #61,-(sp)
  trap #1
  addq.w #8,sp
  move.w d0,handl
  
  pea (a6)
  pea 300000
  move.w d0,-(sp)  
  move.w #63,-(sp)
  trap #1
  lea 12(sp),sp
  
  move.w handl(pc),-(sp)
  move.w #62,-(sp)
  trap #1
  addq.l #4,sp
  rts
  

loaddek move.l a6,-(sp)
  lea 220000,a6
  bsr load
  move.l (sp)+,a4


dekomp
  lea 220032,a6

  clr.l d0
  moveq #$1f,d5
  moveq #$60,d6
  moveq #3,d4
  
*copy first KB direct
 
  move.w #$ff,d1
fkcdl move.l (a6)+,(a4)+
  dbf d1,fkcdl    
  
maind clr.w d0 *prep for dbf
  move.b (a6)+,d0
  bmi.s backc
  beq.s nomore *end
  subq.w #1,d0 *compens dbf
dircl move.b (a6)+,(a4)+
  dbf d0,dircl
  bra.s maind
backc 
  move.b d0,d2
  and.w d5,d2 *d5=$1f
  addq.w #2,d2 *compens
  and.w d6,d0 *d6=$60
  lsl.w d4,d0 *d4=3  (speed!)
  move.b (a6)+,d0 *now we have displac
  move.l a4,a2
  sub.l d0,a2
bakcpl move.b (a2)+,(a4)+
  dbf d2,bakcpl
  bra.s maind
  
nomore   *end of decompress
  rts

  
  
  
n1 dc.b "init.fic",0
n2 dc.b "main.fic",0
n22 dc.b "2dir.fic",0
n3 dc.b "2arest.fic",0
n4 dc.b "gp2b.dsc",0
n5 dc.b "gp3a.dsc",0
n6 dc.b "gp3b.dsc",0
n7 dc.b "gp4a.dsc",0
n8 dc.b "gp4b.dsc",0
  even  
stor ds.b 40


*crp_buf   ds.l   2
*save_pmmuadr   ds.l   1
h_pmmutree   ds.b   256 + 16



       
  end
           